package main

import (
	"reflect"
	"log"
	"runtime"
)

type user struct {
	name string `json:"Name"`
	Age int
}

func main() {

	log.Println("typeOf valueOf-------")
	var str string = "sfsdf"
	strType := reflect.TypeOf(str)
	log.Println(strType)
	log.Println(reflect.ValueOf(str))
	log.Println(reflect.TypeOf(make(chan int)))
	log.Println(reflect.TypeOf(make(map[string]map[string]string)))

	log.Println("修改值-------")
	var x float64 = 3.4
	v := reflect.ValueOf(&x)
	elem := v.Elem()
	elem.SetFloat(5.5)
	log.Println(x)

	log.Println("struct-------")

	st :=  user{Age:33, name:"myname"}

	structType := reflect.TypeOf(st)
	structValue := reflect.ValueOf(st)

	log.Println(structType, structValue)

	log.Println(structType.NumField())

	if field, b := structType.FieldByName("name"); b {
		log.Println(field.Index, field.Tag, field.Name, field.Type)
	}


	log.Println(runtime.NumGoroutine())


}
